package com.general.web.controller.message;

import com.general.common.core.controller.BaseController;
import com.general.common.core.domain.AjaxResult;
import com.general.message.notice.service.INoticeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/notice")
public class NoticeInfoController extends BaseController {

    @Autowired
    private INoticeInfoService noticeInfoService;
    /**
     * 我的通知
     *
     * @return {@code AjaxResult}
     */
    @GetMapping("/my")
    public AjaxResult allMyNotification() {
        return AjaxResult.success(noticeInfoService.getAllInfo());
    }

    /**
     * 修改为已读
     */
    @PostMapping("/read/no/{noticeId}")
    public AjaxResult readNotice(@PathVariable int noticeId) {
        return AjaxResult.success(noticeInfoService.readNotice(noticeId));
    }

    /**
     * 全部已读
     *
     * @return {@code AjaxResult}
     */
    @PostMapping("/read/all")
    public AjaxResult readAllNotice() {
        return AjaxResult.success(noticeInfoService.readAllNotice());
    }
}
